(function ($) {

    var mask;

    function create() {
        if (mask == null) {
            mask = $('.js-image-set-viewer-selector-mask');
            if (mask.length == 0) {
                mask = $('<div class="js-image-set-viewer-selector-mask">').css({
                    'position': 'fixed',
                    'top': 0,
                    'left': 0,
                    'bottom': 0,
                    'right': 0,
                    'z-index': 100,
                    'display': 'none',
                    'background-color': 'rgba(0,0,0,.8)'
                }).appendTo($(document.body));
            }
        }
    }

    $.pageMask = (function () {
        return {
            show: function () {
                create();
                mask.show();
            },
            hide: function () {
                create();
                mask.hide();
            }
        }
    })();
})(jQuery);